package com.song.shenghua.match.controller;

import com.song.shenghua.common.annotation.Log;
import com.song.shenghua.common.core.controller.BaseController;
import com.song.shenghua.common.core.domain.AjaxResult;
import com.song.shenghua.common.core.page.TableDataInfo;
import com.song.shenghua.common.enums.BusinessType;
import com.song.shenghua.common.utils.poi.ExcelUtil;
import com.song.shenghua.match.domain.MatchEquipment;
import com.song.shenghua.match.service.IMatchEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author å®è¿å
 * @date 2021-03-07
 */
@RestController
@RequestMapping("/match/equipment")
public class MatchEquipmentController extends BaseController
{
    @Autowired
    private IMatchEquipmentService matchEquipmentService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MatchEquipment matchEquipment)
    {
        startPage();
        List<MatchEquipment> list = matchEquipmentService.selectMatchEquipmentList(matchEquipment);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MatchEquipment matchEquipment)
    {
        List<MatchEquipment> list = matchEquipmentService.selectMatchEquipmentList(matchEquipment);
        ExcelUtil<MatchEquipment> util = new ExcelUtil<MatchEquipment>(MatchEquipment.class);
        return util.exportExcel(list, "equipment");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(matchEquipmentService.selectMatchEquipmentById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MatchEquipment matchEquipment)
    {
        return toAjax(matchEquipmentService.insertMatchEquipment(matchEquipment));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MatchEquipment matchEquipment)
    {
        return toAjax(matchEquipmentService.updateMatchEquipment(matchEquipment));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(matchEquipmentService.deleteMatchEquipmentByIds(ids));
    }

//    获取用户在线设备列表

    @GetMapping("/online/{id}")
    public AjaxResult online(@PathVariable String ids){


        return null;
    }
}
